<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8" />
	<title>配送地址</title>
	<link rel="stylesheet" type="text/css" href="./Public/Home/css/address.css"/>
	<script src="./Public/Home/js/jquery.min1.9.js" type="text/javascript" charset="utf-8"></script>
	<script src="./Public/Home/js/index.js" type="text/javascript" charset="utf-8"></script>
	<script src="./Public/Home/js/area.js" type="text/javascript" charset="utf-8"></script>
	<link rel="stylesheet" href="./Public/Home/css/sanji.css">
	<script>
		$(function () {
            $('.button-light').click(function () {
                $(this).siblings('.g').show();
            })
            $('.save').click(function () {
                $(this).parents('.g').hide();
            })
        })
	</script>
    <script>
        $(function () {
            $('.save').click(function () {
                //表单序列化
                var data=$('.g').serialize();
                data=decodeURIComponent(data,true);
//                alert(data);
                $.ajax({
                        type:'post',
                        url:'{{U('Address/add')}}',
                    data:data,
                    dataType:'json',
                    success:function(phpData){
//                    alert(phpData);
                    var html = '<li style="height: 44px; margin-left: 33px;"><input type="radio" name="addressid" value="'+phpData.aid+'">';
                    html+='&nbsp;&nbsp;&nbsp;&nbsp;'+phpData.aname
                    html+='&nbsp;&nbsp;&nbsp;&nbsp;'+phpData.aphone;
                    html+='&nbsp;&nbsp;&nbsp;&nbsp;'+phpData.aaddress;
                    html+='&nbsp;&nbsp;&nbsp;&nbsp;'+phpData.amail;
                    html+=' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+'<a href="">删除</a>'+'</li>';
//						alert(html);
                    $('#address ul').append(html);

                }
                 })
            })
        })
    </script>

</head>
<body>
	<!--头部条开始-->
	{{include file="../Common/header"}}
	
	<!--内容开始-->
	<div class="main-content-user">
		<div class="wrapper">
			<ul class="breadcrumb">
				<li>
					<a href="">首页</a>
					<span>/</span>
				</li>
				<li>
					配送地址
				</li>
			</ul>
			<div class="myOppo-menu">
				<h2 class="h-gamma">配送地址</h2>
				<ul class="navigation">
					
					<li >
						<a  href="{{U('User/index')}}">账户信息</a>
					</li >
					<li class="active">
						<a href="{{U('User/add')}}">配送地址</a>
					</li>
					<li>
						<a href="{{U('User/form')}}">我的订单</a>
					</li>	
				</ul>
			</div>

			<div class="brick-shadow">
                <div id="address">
                    <ul>
                        {{foreach from="$addressData" value="$v"}}
                        <li style="height: 44px; margin-left: 33px"><input type="radio" name="addressid" value="{{$v['aid']}}">&nbsp;&nbsp;&nbsp;&nbsp;{{$v['aname']}}&nbsp;&nbsp;&nbsp;&nbsp;{{$v['aphone']}}&nbsp;&nbsp;&nbsp;&nbsp;{{$v['aaddress']}}&nbsp;&nbsp;&nbsp;&nbsp;{{$v['amail']}}
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="{{U('User/del',array('aid'=>$v['aid']))}}">
                                删除
                            </a></li>
                        {{endforeach}}
                    </ul>
                </div>
                <a class="button-light" href="javascript:;"style="display:block;width: 88px;height: 20px;">添加新地址</a>
                <form action="" method="post" class="g"style="display: none">
                    <div class="address-create" >
                    <div class="con">
                        <label>*收货人姓名</label>
                        <input type="text" name="aname" id="" class="uname" value="" />
                    </div>

                    <div class="tel">
                        <label>*手机号码</label>
                        <input type="text" name="aphone" class="phone"/>
                    </div>
                    <div class="address">
                        <label>*收货地址</label>

                        <div class="info">
                            <div>
                                <select id="s_province" name="aaddress[]" ></select>  
                                <select id="s_city" name="aaddress[]" ></select>  
                                <select id="s_county" name="aaddress[]"></select>
                                <script class="resources library" src="area.js" type="text/javascript"></script>

                                <script type="text/javascript">_init_area();</script>
                            </div>
                            <div id="show"></div>
                        </div>
                        <script type="text/javascript">
                            var Gid  = document.getElementById ;
                            var showArea = function(){
                                Gid('show').innerHTML = "<h3>省" + Gid('s_province').value + " - 市" +
                                    Gid('s_city').value + " - 县/区" +
                                    Gid('s_county').value + "</h3>"
                            }
                            Gid('s_county').setAttribute('onchange','showArea()');
                        </script>
                        <input type="text" name="address-detail" class="address-detail" placeholder="详细街道地址"/>

                    </div>

                    <div class="emal">
                        <label>邮箱</label>
                        <input type="text" name="amail" class="mail"/>
                    </div>

                    <div class="form-actions">
                        <div class="pull-left">
                            <a href="javascript:;" class="save">保存</a>
                            <a href="javascript:;" class="cancel">取消</a>

                        </div>


                    </div>
                </div>
                </form>
			</div>		
		</div>
	</div>
	<!--内容结束-->
	
	

	

	
	

	<!--公共底部-->
	{{include file="../Common/footer"}}
	

</body>
</html>